package models

import (
	"database/sql"

	_ "github.com/go-sql-driver/mysql"
)

var (
	db *sql.DB
)

func GetDb() *sql.DB {
	if db != nil {
		return db
	}
	d, err := sql.Open("mysql", "root:123qwe@tcp(127.0.0.1:3306)/test?charset=utf8")
	if err != nil {
		panic(err.Error())
	}
	db = d
	return db
}
